﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.IO;

namespace GraphTheory.Task1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Matrix.Text = "2\n0 1\n1 0";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Graph counter = new Graph(Matrix.Text, GraphType.UndirectedGraphFromString);
            System.Windows.MessageBox.Show("Компонент связности: " + counter.CalculateNumberOfConnectedComponents().ToString(), "Количество компонент связности");
        }

        private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
        {

        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.UndirectedGraphFromString);
            System.Windows.MessageBox.Show(graph.IsEuler() == 0 ? "Эйлеров" : "Не Эйлеров, обход остановлен на вершине " + graph.IsEuler().ToString(), "Эйлеровость");
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            if (System.Windows.Forms.DialogResult.OK == dialog.ShowDialog())
            {
                StreamReader reader = new StreamReader(dialog.OpenFile());
                Matrix.Text = reader.ReadToEnd();
            }
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.UndirectedGraphFromString);
            try
            {
                System.Windows.Forms.MessageBox.Show(graph.IsChordal() ? "Граф скорее всего ходральный, так как есть смежно-поглощающая вершина" : "Граф - не хордальный", "Хордальность");
            }
            catch (NotImplementedException ex)
            {
                System.Windows.MessageBox.Show("Not yet implemented");
            }
        }

        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.UndirectedGraphFromString);
            try
            {
                System.Windows.Forms.MessageBox.Show("Независимое множество: " + graph.GetIndependentSet());
            }
            catch (NotImplementedException)
            {
                System.Windows.Forms.MessageBox.Show("Not yet implemented");
            }           
        }

        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.UndirectedGraphFromString);
            try
            {
                System.Windows.Forms.MessageBox.Show("Раскраска: " + graph.GetColoring());
            }
            catch (NotImplementedException)
            {
                System.Windows.Forms.MessageBox.Show("Not yet inmplemented");
            }
           
        }

        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.DirectedGraphFromString);
            try
            {
                System.Windows.Forms.MessageBox.Show("Кратчайшие пути до вершин графа" + graph.BellmanFord()+"\n Если необходимо получит и сами пути, сообщите разработчику");
            }
            catch (NotImplementedException)
            {
                System.Windows.Forms.MessageBox.Show("Not yet implemented");
            }
        }

        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            Graph graph = new Graph(Matrix.Text, GraphType.DirectedGraphFromString);
            try
            {
                System.Windows.Forms.MessageBox.Show("Кратчайшие пути между вершинами:\n"+ graph.FloydWorshell());
            }
            catch (NotImplementedException)
            {
                System.Windows.Forms.MessageBox.Show("Not yet implemented");
            }
        }
    }
}
